package com.example.mybiadushoujiweishi.activity.acivitys.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.example.mybiadushoujiweishi.R;
import com.example.mybiadushoujiweishi.activity.acivitys.entity.Contact;
import com.example.mybiadushoujiweishi.activity.acivitys.utils.MyApplication;


import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/13 0013.
 */

public class SOSAdapter extends RecyclerView.Adapter<SOSAdapter.MyviewHoloder> {

    List<Contact> list;

    public SOSAdapter(List<Contact> list) {
        this.list = list;
    }

    @Override
    public MyviewHoloder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(MyApplication.getContext()).inflate(R.layout.sos_contact_iteml, parent, false);
        MyviewHoloder myviewHoloder=new MyviewHoloder(view);

        return myviewHoloder;
    }

    @Override
    public void onBindViewHolder(MyviewHoloder holder, int position) {

        Contact contact=list.get(position);
        holder.name.setText(contact.getData());
        holder.phonenumber.setText(contact.getPhonenum());
        holder.textAddr.setText(contact.getAddress());


    }

    @Override
    public int getItemCount() {

        return list.size();
    }

    class MyviewHoloder extends RecyclerView.ViewHolder {

        @BindView(R.id.name)
        TextView name;
        @BindView(R.id.phonenumber)
        TextView phonenumber;
        @BindView(R.id.text_addr)
        TextView textAddr;
        public MyviewHoloder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }


}
